/**
* 版权所有：福建邮科电信业务部厦门研发中心 
*====================================================
* 文件名称: CreateThumbFileHandler.java
* 修订记录：
* No    日期				作者(操作:具体内容)
* 1.    2013-4-11			詹保山(创建:创建文件)
*====================================================
* 类描述：(说明未实现或其它不应生成javadoc的内容)
* 
*/
package com.devframe.srtp.client.handle;

import java.net.URI;

import org.jboss.netty.handler.codec.http.multipart.HttpDataFactory;
import org.jboss.netty.handler.codec.http.multipart.HttpPostRequestEncoder;
import org.jboss.netty.handler.codec.http.multipart.HttpPostRequestEncoder.ErrorDataEncoderException;

import com.devframe.srtp.SRTPConstants;
import com.devframe.srtp.util.enumobj.EnumSRTPAction;

public class ClientCreateThumbPictureHandler extends ClientWrapFileHandler {
	private String filePath;
	public ClientCreateThumbPictureHandler(String host, URI uri, String userName,
			String pwd,String filePath) {
		super(host, uri, userName, pwd);
		this.filePath=filePath;
		
	}

	public HttpPostRequestEncoder wrapRequestData(HttpDataFactory factory) {
		
        HttpPostRequestEncoder bodyRequestEncoder = null;
        try {
            bodyRequestEncoder = new HttpPostRequestEncoder(factory, this.getRequest(), false); // true => multipart
        } catch (NullPointerException e) {
            e.printStackTrace();
        } catch (ErrorDataEncoderException e) {
            e.printStackTrace();
        }
        //设置参数
        try {
            bodyRequestEncoder.addBodyAttribute("getform", "POST");
            bodyRequestEncoder.addBodyAttribute(SRTPConstants.ACTION_KEY, EnumSRTPAction.CREATE_THUMB_PICTURE.getValue());
            bodyRequestEncoder.addBodyAttribute(SRTPConstants.FILE_PATH_KEY, this.filePath);
            bodyRequestEncoder.addBodyAttribute(SRTPConstants.USER_NAME_KEY, super.getUserName());
            bodyRequestEncoder.addBodyAttribute(SRTPConstants.PWD_KEY, super.getPwd());
            
        } catch (NullPointerException e) {
            e.printStackTrace();
        } catch (ErrorDataEncoderException e) {
            e.printStackTrace();
        }
        try {
            bodyRequestEncoder.finalizeRequest();
        } catch (ErrorDataEncoderException e) {
            e.printStackTrace();
        }
		return bodyRequestEncoder;
	}

}
